<template>
<div>
  <van-field v-model="tel" placeholder="请设置密码" />
  <van-button @click="register" :disabled="flag" round type="danger" block>完成</van-button>
</div>
</template>

<script>
import Vue from 'vue'
import { Field, Button, Dialog } from 'vant'
import { dofinishregister } from './../../api/user'
Vue.use(Field)
Vue.use(Button)
Vue.use(Dialog)
export default {
  computed: {
    flag () {
      return this.password.length < 5
    }
  },
  data () {
    return {
      tel: '',
      password: ''
    }
  },
  methods: {
    register () {
      dofinishregister({
        tel: localStorage.getItem('tel'),
        password: this.password
      }).then(res => {
        Dialog.confirm({
          message: '注册成功，继续登录'
        })
        .then(() => {
          //this.$router.push('/login')
          this.$router.go(-3)
        })
        .catch(() => {
          //on cance
        })
      })
    }
  }
}
</script>
